export const travel = <T extends {[key: string]: any}, K extends keyof T>(node: T, fn: (val: T[K]) => T[K]) => {
    return Object.keys(node).reduce((obj: any, key: string) => {
        const itemVal = node[key];
        if (Array.isArray(itemVal)) {
            obj[key] = itemVal.map(i => fn(i));
        } 
        obj[key] = fn(itemVal);
        return obj;
    }, {});
}